package com.zhaohanlin.start;

import java.util.Scanner;

/**
 * @author zhaohanlin
 */

public class ScannerTest {
    public static void main(String[] args) {
        Scanner scanner = new Scanner(System.in);
        System.out.println("欢迎来到计算器");
        while (true) {
            System.out.println("请输入第一个数");
            int numA = scanner.nextInt();
            System.out.println("请输入运算法则，输入对应的编号");
            System.out.println("1加法");
            System.out.println("2减法");
            System.out.println("3除法");
            System.out.println("4取余");
            int operator = scanner.nextInt();
            System.out.println("请输入第二个数字");
            int numB = scanner.nextInt();
            String result =
                    operator == 1 ? String.valueOf(numA + numB) :
                            operator == 2 ? String.valueOf(numA + numB) :
                                    operator == 4 ? String.valueOf(numA / numB) :
                                            operator == 5 ? String.valueOf(numA % numB) : ("输入有误！");

            System.out.println("最终计算结果是：" + result);

        }
    }
}


